package com.core.zyyz.amc.modules.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.core.common.annotation.Log;
import com.core.common.core.controller.BaseController;
import com.core.common.core.domain.AjaxResult;
import com.core.common.enums.BusinessType;
import com.core.zyyz.amc.modules.domain.AmcI18nLanguageB;
import com.core.zyyz.amc.modules.service.AmcI18nLanguageBService;
import com.core.common.core.page.TableDataInfo;

/**
 * 国际化语言Controller
 *
 * @author LiuFushun
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/amc/international")
public class AmcI18nLanguageBController extends BaseController
{
    @Autowired
    private AmcI18nLanguageBService amcI18nLanguageBService;

    /**
     * 查询国际化语言列表
     */
    @PreAuthorize("@ss.hasPermi('amc:international:list')")
    @GetMapping("/list")
    public TableDataInfo list(AmcI18nLanguageB amcI18nLanguageB) {
        startPage();
        List<AmcI18nLanguageB> list = amcI18nLanguageBService.selectAmcI18nLanguageBList(amcI18nLanguageB);
        return getDataTable(list);
    }


    /**
     * 获取国际化语言详细信息
     */
    @PreAuthorize("@ss.hasPermi('amc:international:query')")
    @GetMapping(value = "/{cnVal}")
    public AjaxResult getInfo(@PathVariable("cnVal") String cnVal)
    {
        return success(amcI18nLanguageBService.selectAmcI18nLanguageBByI18nKey(cnVal));
    }

    /**
     * 新增国际化语言
     */
    @PreAuthorize("@ss.hasPermi('amc:international:add')")
    @Log(title = "国际化语言", businessType = BusinessType.INSERT)
    @PostMapping("/insertI18")
    public AjaxResult add(@RequestBody AmcI18nLanguageB amcI18nLanguageB) {
        AmcI18nLanguageB entity = amcI18nLanguageBService.selectAmcI18nLanguageBByI18nKey(amcI18nLanguageB.getCnVal());
        if (null != entity){
            return warn("配置表中已存在该中文信息!!!");
        }else {
            return toAjax(amcI18nLanguageBService.insertAmcI18nLanguageB(amcI18nLanguageB));
        }
    }

    /**
     * 修改国际化语言
     */
    @PreAuthorize("@ss.hasPermi('amc:international:edit')")
    @Log(title = "国际化语言", businessType = BusinessType.UPDATE)
    @PostMapping("/updateI18")
    public AjaxResult edit(@RequestBody AmcI18nLanguageB amcI18nLanguageB) {
        return toAjax(amcI18nLanguageBService.updateAmcI18nLanguageB(amcI18nLanguageB));
    }

    /**
     * 删除国际化语言
     */
    @PreAuthorize("@ss.hasPermi('amc:international:remove')")
    @Log(title = "国际化语言", businessType = BusinessType.DELETE)
    @DeleteMapping("/{i18nKeys}")
    public AjaxResult remove(@PathVariable String[] i18nKeys)
    {
        return toAjax(amcI18nLanguageBService.deleteAmcI18nLanguageBByI18nKeys(i18nKeys));
    }
}
